///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
#ifndef __OBJECT_H__
#define __OBJECT_H__

#include <Config.h>
#include <Scene/Mover.h>
#include <vector>
#include <tinyxml.h>

class	Mesh;
class	SceneManager;

//-----------------------------------------------------------------------------

class Object
	:	public Mover
{
public:
	/*
	*	Constructor - destructor
	*/
							Object();
	virtual					~Object();

	/*
	*	Draw the model.
	*/
	void					Update(f32 dt);
	void 					Draw();

	/*
	*	Scene management
	*/
	SceneManager*			GetSceneManager();
	void					SetSceneManager(SceneManager* scene);

	/*
	*	Child-parent hierarchy
	*/	
	void					AddChild(Object* child);
	void					RemoveChild(Object* child);
	std::vector<Object*>&	GetChildren();
	void					SetParent(Object* parent);
	Object*					GetParent();
	
	/*
	*	Visibility
	*/
	void					SetVisible(bool visible);
	bool					IsVisible();

	/*
	*	Meshes
	*/
	void					AddMesh( Mesh*	mesh );
	u16						GetMeshCount();
	Mesh*					GetMesh( u16 index );
	//void					SetMesh( Mesh*	mesh );
	//Mesh*					GetMesh();

	/*
	*	Parse XML Element
	*/
	void					ParseElement(TiXmlElement* elem);

	/*
	*	Transforms
	*/
	Matrix4x4				GetRelativeTransform();
	void					SetRelativeTransform(const Matrix4x4& mat);
	Matrix4x4				GetAbsoluteTransform();
	void					updateRelativeTransform();
	void					updateAbsoluteTransform();

private:

	Object*					m_parent;
	std::vector<Object*>	m_children;

	SceneManager*			m_sceneManager;

	Matrix4x4				m_relativeTransform;
	Matrix4x4				m_absoluteTransform;

	bool					m_isVisible;

	std::vector<Mesh*>		m_meshes;
	//Mesh*					m_mesh;

};

#endif // __OBJECT_H__
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
